package com.company.cuobuliao.ui.user;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.company.cuobuliao.R;
import com.company.cuobuliao.adapter.ClassMateAdapter;
import com.company.cuobuliao.base.BaseActivity;
import com.company.cuobuliao.model.ClassMate;
import com.company.cuobuliao.ui.me.ClassInfoActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Oreo on 2017/8/14.
 */

public class MeActivity extends BaseActivity implements View.OnClickListener {

    private ListView listView;
    private List<ClassMate> list = new ArrayList<>();
    private ClassMateAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ui_me);
        initView();
        fucGetData();
    }

    private void initView() {
        back(R.id.rllyBack);

        findViewById(R.id.tvInfo).setOnClickListener(this);
        findViewById(R.id.tvClass).setOnClickListener(this);

        listView = (ListView) findViewById(R.id.listView);
        adapter = new ClassMateAdapter(this, list);
        listView.setAdapter(adapter);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                startActivity(new Intent(MeActivity.this, ClassInfoActivity.class));
            }
        });
    }

    private void fucGetData() {
        list.add(new ClassMate());
        list.add(new ClassMate());
        list.add(new ClassMate());
        list.add(new ClassMate());
        adapter.notifyDataSetChanged();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tvInfo:
                findViewById(R.id.vInfo).setBackgroundResource(R.color.orange2);
                findViewById(R.id.vClass).setBackgroundResource(R.color.orange);
                findViewById(R.id.includeInfo).setVisibility(View.VISIBLE);
                findViewById(R.id.includeClass).setVisibility(View.GONE);
                break;
            case R.id.tvClass:
                findViewById(R.id.vInfo).setBackgroundResource(R.color.orange);
                findViewById(R.id.vClass).setBackgroundResource(R.color.orange2);
                findViewById(R.id.includeInfo).setVisibility(View.GONE);
                findViewById(R.id.includeClass).setVisibility(View.VISIBLE);
                break;
        }
    }
}
